<?php

namespace App\Http\Controllers\Admin\Author;
use App\Http\Requests\BooksPostRequest;
use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class ExtraController extends Controller
{
   public function getAddgg($aid)
   {
        // return 'asdsdfvd';

        $gg = DB::table('hs_ext')->where('aid',$aid)->select('gg')->first();
        
        if($gg){
           return view('admin.author.gg.add',['gg'=>$gg]);
         }else{
           return view('admin.author.gg.add',['gg'=>'']);
         }
       
   }

  
   public function postInsert(Request $request)
   {
        $data = $request->except('_token');
        // dd($data);
        $res = DB::table('hs_ext')->where('aid',$data['aid'])->first();
        if($res){
            $rr = DB::table('hs_ext')->where('aid',$data['aid'])->update(['gg'=>$data['gg']]);
            return back()->with('success','发布公告成功');
        }else{
            DB::table('hs_ext')->insert($data);
        }

   }

    public function getAddtj($aid)
   {
         $tj = DB::table('hs_ext')->where('aid',$aid)->select('tj')->first();
         // dd($tj);
         if($tj){
             return view('admin.author.tj.add',['tj'=>$tj]);
         }else{
            return view('admin.author.tj.add',['tj'=>'']);
         }
        
   }

   public function postInsertt(Request $request)
   {
        $data = $request->except('_token');
        // dd($data);
        $res = DB::table('hs_ext')->where('aid',$data['aid'])->first();
        if($res){
            $rr = DB::table('hs_ext')->where('aid',$data['aid'])->update(['tj'=>$data['tj']]);
            return back()->with('success','发布公告成功');
        }else{
            DB::table('hs_ext')->insert($data);
            return back()->with('success','发布公告成功');
        }

   }

}
